<%@ page language="java" import="java.util.*" import="com.gxuwz.medical.domain.area.*" import="com.gxuwz.medical.domain.family.*"   pageEncoding="utf-8" %>
<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta name="renderer" content="webkit">
<title></title>
<link rel="stylesheet" href="../../css/pintuer.css">
<link rel="stylesheet" href="../../css/admin.css">
<script src="../../js/jquery-1.4.4.min.js"></script>
<script src="../../js/pintuer.js"></script>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<script>
$(function(){
/*
绑定onchange事件回调函数
*/
	$("#town").change(getvillage);
	$("#village").change(getgroup);
	dispatchEvent("town");
});


function getvillage(){
	var areacode = $(this).val();
    console.log(areacode);
    var htmlobj=$.ajax({url:"/medical/system/FamilyServlet?method=getchild&areapcode="+areacode,async:false});
    console.log(htmlobj.responseText);
    var areaArr = JSON.parse(htmlobj.responseText);
    var selected = document.getElementById("village");
    var options =selected.options;
    selected.length=0;
    for(var i=0;i<areaArr.length;i++){
    	document.getElementById("village").options.add(new Option(areaArr[i].areaname,areaArr[i].areacode));
    }
    dispatchEvent("village");
}
function getgroup(){
	var areacode = $(this).val();
    console.log(areacode);
    var htmlobj=$.ajax({url:"/medical/system/FamilyServlet?method=getchild&areapcode="+areacode,async:false});
    console.log(htmlobj.responseText);
    var areaArr = JSON.parse(htmlobj.responseText);
    document.getElementById("group").length=0;
    for(var i=0;i<areaArr.length;i++){
    	document.getElementById("group").options.add(new Option(areaArr[i].areaname,areaArr[i].areacode));
    }
}

function dispatchEvent(id){
	var event = document.createEvent("HTMLEvents");
	event.initEvent("change", true, true);
	document.querySelector("#"+id).dispatchEvent(event);
}

 
</script>
</head>
<body>

<div class="panel admin-panel">
  <div class="panel-head" id="add"><strong><span class="icon-pencil-square-o"></span>添加家庭档案</strong></div>
  <div class="body-content">
    <form method="post" class="form-x" action="<%=path %>/system/FamilyServlet?method=add"> 
	<div class="form-group">
        <div class="label">
          <label>户口属性：</label>
        </div>
        <div class="field">
          <select name="familyattribute" required>
         	<option  value="一般户">一般户</option>
            <option  value="五保户">五保户</option>
            <option  value="军烈属">军烈属</option>
        </select>
	    </div>
      </div>

		<div class="form-group">
	        <div class="label">
	          <label>镇级行政区域：</label>
	        </div>
	        <div class="field">
	        <select name="town" id="town" required>
	        
	         <%
	        	Area a = new Area();
	        	List<Area> townlist = a.getListbyLevel(2);
	        	for(int i=0;i<townlist.size();i++){
	        	
	         %>
	         	<option  value="<%=townlist.get(i).getAreacode()%>">
	         	<%=townlist.get(i).getAreaname()%>
	         	</option>
	         <%
	         	}
	          %>       
	        </select>
		    </div>
	      </div>

		<div class="form-group" >
	        <div class="label">
	          <label>村级行政区域：</label>
	        </div>
	        <div class="field">
	        <select name="village" id="village" required>
	        
	        </select>
		    </div>
	      </div>	
	      
		<div class="form-group">
	        <div class="label">
	          <label>组级行政区域：</label>
	        </div>
	        <div class="field">
	        <select name="group" id="group">
	        
	        </select>
		    </div>
	      </div>      
      
      <div class="form-group">
        <div class="label">
          <label>家庭住址：</label>
        </div>
        <div class="field">
          <input type="text" class="input w50" value="" name="address" data-validate="required:请输入家庭住址" />
	    </div>
      </div>
      

      

      
      <div class="form-group">
        <div class="label">
          <label>户主姓名：</label>
        </div>
        <div class="field">
          <input type="text" class="input w50" value="" name="fullname" data-validate="required:请输入户主姓名" />
	    </div>
      </div>
      
      <div class="form-group">
        <div class="label">
          <label>户主身份证号：</label>
        </div>
        <div class="field">
          <input type="text" class="input w50" value="" name="idcard" maxlength="18" data-validate="required:请输入户主身份证号" />
	    </div>
      </div>
      
      <div class="form-group">
        <div class="label">
          <label>与户主关系：</label>
        </div>
        <div class="field">
          <select name="relative" >
         	<option  value="户主" selected="selected">户主</option>
        </select>
	    </div>
      </div>
      

      
      <div class="form-group">
        <div class="label">
          <label>户主性别：</label>
        </div>
        <div class="field">
        <select name="sex">
         	<option  value="男">男</option>
            <option  value="女">女</option>
        </select>
	    </div>
      </div>
      
      <div class="form-group">
        <div class="label">
          <label>户主民族：</label>
        </div>
        <div class="field">
          <select name="nation">
         	<option  value="汉族">汉族</option>
            <option  value="壮族">壮族</option>
            <option  value="其他少数民族">其他少数民族</option>
        </select>
	    </div>
      </div>
      <div class="form-group">
        <div class="label">
          <label>户主健康状况：</label>
        </div>
        <div class="field">
          <select name="health">
         	<option  value="健康">健康</option>
            <option  value="残疾">残疾</option>
            <option  value="疾病">疾病</option>
        </select>
	    </div>
      </div>
      <div class="form-group">
        <div class="label">
          <label>户主文化程度：</label>
        </div>
        <div class="field">
          <select name="culture">
         	<option  value="小学及以下">小学及以下</option>
            <option  value="初中">初中</option>
            <option  value="高中">高中</option>
            <option  value="大学及以上">大学及以上</option>
        </select>
	    </div>
      </div>
      <div class="form-group">
        <div class="label">
          <label>人员属性：</label>
        </div>
        <div class="field">
          <select name="attribute">
         	<option  value="群众">群众</option>
            <option  value="共青团员">共青团员</option>.
            <option  value="中共党员">中共党员</option>
        </select>
	    </div>
      </div>
      
      <div class="form-group">
        <div class="label">
          <label>是否农业人员：</label>
        </div>
        <div class="field">
        <select name="farmer">
         	<option  value="是">是</option>
            <option  value="否">否</option>
        </select>
	    </div>
      </div>
      
      <div class="form-group">
        <div class="label">
          <label>户主婚姻状态：</label>
        </div>
        <div class="field">
        <select name="marry">
         	<option  value="已婚">已婚</option>
            <option  value="未婚">未婚</option>
        </select>
	    </div>
      </div>
      
      <div class="form-group">
        <div class="label">
          <label>工作单位：</label>
        </div>
        <div class="field">
          <input type="text" class="input w50" value="" name="workunit" data-validate="required:请输入工作单位" />
	    </div>
      </div>
      <div class="form-group">
        <div class="label">
          <label>联系电话：</label>
        </div>
        <div class="field">
          <input type="text" class="input w50" value="" name="tel" data-validate="required:请输入联系电话" />
	    </div>
      </div>
      
      <div class="form-group">
        <div class="label">
          <label></label>
        </div>
        <div class="field">
          <button class="button bg-main icon-check-square-o" type="submit"> 提交</button>
        </div>
      </div>
      
    </form>
  </div>
</div>

</body></html>